package com.cgydu.service.impl;

import com.cgydu.dao.TypeDao;
import com.cgydu.dao.impl.TypeDaoImpl;
import com.cgydu.entity.Message;
import com.cgydu.entity.Type;
import com.cgydu.service.TypeService;
import com.cgydu.utils.Constants;

import java.sql.SQLException;
import java.util.List;

/**
 * projectName: day25_store
 * author: CGY
 * time: 2020/8/27 16:50
 * description:
 */
public class TypeServiceImpl implements TypeService {
    @Override
    public Message findTypes() throws SQLException {

        TypeDao typeDao = new TypeDaoImpl();

        //最多截取六个
        List<Type> types = typeDao.queryTypes(6);

        Message message = new Message();

        if (types !=null && types.size()>0){

            message.setCode(Constants.MESSAGE_SUCCESS);
            message.setData(types);

        }

        return message;
    }
}
